﻿using System.AutoUpdate.Tools;
using System.Collections.Generic;
using System.Reflection;

namespace System.AutoUpdate.Library
{
    public class UpdateInfo
    {
        public SortedSet<UpdateVersionInfo> AvailableVersions
        {
            get;
            protected set;
        }

        public int Count
        {
            get
            {
                return AvailableVersions.Count;
            }
        }

        public long UpdateSize
        {
            get
            {
                long updateSize = 0;

                foreach (UpdateVersionInfo version in AvailableVersions)
                {
                    updateSize += version.File.FileSize;
                }

                return updateSize;
            }
        }

        public string TemporaryDirectory
        {
            get;
            set;
        }

        public string ApplicationRoot
        {
            get;
            set;
        }

        public UpdatePackage UpdatePackage
        {
            get;
            set;
        }

        public UpdateInfo ()
        {
            AvailableVersions = new SortedSet<UpdateVersionInfo> (new UpdateVersionInfoComparer ());

            TemporaryDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            ApplicationRoot = Assembly.GetEntryAssembly().Location;
        }
    }
}
